<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>Document</title>
  </head>
  <body>
    <script>
      const arr = [
        {
          depname: '123',
          depcode: 1,
          children: [
            {
              depname: '345',
              depcode: 1.1,
              children: null,
            },
          ],
        },
        {
          depname: '223',
          depcode: 2,
          children: [
            {
              depname: '345',
              depcode: 2.1,
              children: null,
            },
          ],
        },
      ]

      const newArr = arr.map((item) => {
        return {
          title: item.depname,
          key: item.depcode,
          children: item.children.map((item) => {
            return {
              title: item.depname,
              key: item.depcode,
              children: null,
            }
          }),
        }
      })
      console.log(newArr)
    </script>
  </body>
</html>
